package leetcode.Leetcode283;

class DraftSolution {
    public void moveZeroes(int[] nums) {
        int j=0;
        for (int i = 0; i < nums.length; ++i) {
            //当且仅当
            if (nums[i] != 0) {
                nums[j++] = nums[i];
            }
        }
        for (int i = j; i < nums.length; i++) {
            nums[i] = 0;
        }
    }

    public static void main(String[] args) {
        DraftSolution draftSolution = new DraftSolution();
        draftSolution.moveZeroes(new int[]{1,2});
    }
}